#前缀数组的应用，以及二分查找的应用


from bisect import bisect_right
def max_tg(n, m, k, a, b):
    a_pr = [0] * (n + 1)
    b_pr = [0] * (m + 1)
    for i in range(1, n + 1):
        a_pr[i] = a_pr[i - 1] + a[i - 1]
    for i in range(1, m + 1):
        b_pr[i] = b_pr[i - 1] + b[i - 1]
    max_levels = 0
    for i in range(n + 1):
        if a_pr[i] > k:
            break
        en = k - a_pr[i]
        j = bisect_right(b_pr,en) - 1
        max_levels = max(max_levels, i + j)
    return max_levels
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(max_tg(n, m, k, a, b))